<template>
	<view class="uni-flex uni-column uni-bg-white" 
		style="padding:0 64rpx;height:100%;justify-content:center;align-items:center;text-align:center;">
		<view style="padding: 32rpx 0;">
			<image src="../../static/image/hlk.png" style="width:250rpx;height:259rpx;"></image>
		</view>
		<view style="width:100%;">
			<button style="background-color:#07C160;color:#FFFFFF;font-size:14pt;border-radius:100rpx;"
				@click="clickLogin" v-if="!state">手机号快捷登录</button>
			<button open-type="getPhoneNumber" @getphonenumber="getphonenumber"
				style="background-color:#07C160;color:#FFFFFF;font-size:14pt;border-radius:100rpx;" v-else-if="state">手机号快捷登录</button>
		</view>
		
		<view style="padding-top:32rpx;font-size:11pt;">
			<view class="uni-flex uni-row" style="justify-content:center;align-items:center;">
				<view>
					<checkbox-group @change="agreeChange">
						<checkbox style="transform:scale(0.8)" :checked="state"/>
					</checkbox-group>
				</view>
				<view>
					<text>我已阅读并同意</text>
				</view>
				<view style="padding:0 12rpx;">
					<navigator url="../protocol/user_protocol">
						<text style="color:#10AEFF;">用户协议</text>
					</navigator>
				</view>
				<view>
					<text>及</text>
				</view>
				<view style="padding:0 12rpx;">
					<navigator url="../protocol/privacy_protocol">
						<text style="color:#10AEFF;">隐私协议</text>
					</navigator>
				</view>
			</view>
			<view>
				<text>若您的手机号未注册,将为您直接注册海陆空账号</text>
			</view>
		</view>
	</view>
</template>

<script>
	import { API } from "@/util/constant.js";
	import {post} from "@/util/request.js"
	import { wxLogin} from "@/util/api.js"
	
	export default {
		data() {
			return {
				state: false
			}
		},
		methods: {
			agreeChange(e) {
				this.state = !this.state;
			},
			clickLogin(e) {
				var that = this;
				if (!that.state) {
					uni.showToast({
						icon: 'none',
						title:"请阅读并勾选用户协议及隐私协议"
					});
				} else {
					
				}
			},
			getphonenumber(e) {
				
				var phoneNumberCode = e.detail.code;
				if (typeof phoneNumberCode == 'undefined') {
					return;
				}
				wx.login({
					success: function(res) {
						var loginCode = res.code;
						
						var res = wxLogin({
							loginCode: loginCode,
							phoneNumberCode: phoneNumberCode
						});
						
					}
				});
			}
		}
	}
</script>

<style>
page {
	height:100%;
	width:750rpx;
	display:flex;
	justify-content:center;
	align-items:center;
}
</style>
